﻿#region
/* ===============================================
 * 作者：guopeng           时间：2012/3/24 11:21:33
 * 
 * 
 * 类描述：
 * 
 * 
 * =============================================== */
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.Entities;
using ueEngine.Biz.Inf.LogicEntity.SupportData;
using ueEngine.Biz.Inf.Entities.DBSupport;


namespace ueEngine.Biz.Inf.LogicEntity
{
    public class NoticeModel : IAccessible<SystemNotice, NoticeModel>
    {
        #region self
        public int Id { get; set; }

        /// <summary>
        /// 公告标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 公告编辑
        /// </summary>
        public string Editor { get; set; }

        /// <summary>
        /// 公告内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 公告分类
        /// </summary>
        public NoticeType Type { get; set; }

        /// <summary>
        /// 公告子类
        /// </summary>
        public int Subject { get; set; }

        /// <summary>
        /// 发布日期
        /// </summary>
        public DateTime PublishDate { get; set; }
        #endregion

        protected override void Covariant(SystemNotice dbModel)
        {
            this.Content = dbModel.Content;
            this.Editor = dbModel.Editor;
            this.Id = dbModel.Id;
            this.PublishDate = dbModel.PublishDate;
            this.Subject = dbModel.Subject;
            this.Title = dbModel.Title;
            this.Type = (NoticeType)dbModel.Type;
        }
        protected override SystemNotice Inverter(NoticeModel model)
        {
            return new SystemNotice()
            {
                Content = model.Content,
                Editor = model.Editor,
                Id = model.Id,
                PublishDate = model.PublishDate,
                Subject = model.Subject,
                Title = model.Title,
                Type = (int)model.Type
            };
        }

        //public override NoticeModel Element(System.Linq.Expressions.Expression<Func<SystemNotice, bool>> where)
        //{
        //    Covariant(new SystemNotice().Get(where));
        //    return this;
        //}

        //public override List<TResult> Elements<TResult>(System.Linq.Expressions.Expression<Func<SystemNotice, bool>> where, System.Linq.Expressions.Expression<Func<SystemNotice, TResult>> select)
        //{
        //    using (Context ctx = new Context())
        //    {
        //        return ctx.SystemNotice.Where(where).Select(select).ToList();
        //    }
        //}
    }
}
